<template>
    <div class="ticket-item-container">
        <div class="title-wrapper">
            <span class="icon"></span>
            <span class="label">工单状态：</span>
            <span class="button-wrapper" @click="onTicketInfo">
                <span :class="ticket.status === 1 ? 'button' : 'status'">
                    {{ ticket.ticketStatusText }}
                </span>
                <van-icon
                    v-if="ticket.status === 1"
                    name="arrow"
                    color="#677B8E"
                />
            </span>
        </div>
        <div class="content-wrapper">
            <p class="content-line">
                <span class="label">机型：</span>
                <span class="value">{{ ticket.model }}</span>
            </p>
            <p class="content-line">
                <span class="label">设备号：</span>
                <span class="value">{{ ticket.sn }}</span>
            </p>
            <p class="content-line">
                <span class="label">工单号：</span>
                <span class="value">{{ ticket.orderId }} </span>
            </p>
        </div>
        <van-button class="info-button" @click="onTalkInfo">
            通话详情
        </van-button>
        <span v-if="showDivider" class="divider"></span>
        <span v-else class="blank"></span>
    </div>
</template>

<script>
import Vue from "vue";
import { Icon } from "vant";

Vue.use(Icon);
export default {
    components: {},
    props: {
        ticket: {
            type: Object,
            default() {
                return {};
            },
        },
        showDivider: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {};
    },
    created() {},
    mounted() {},
    methods: {
        onTicketInfo() {
            if (this.ticket.status !== 1) {
                return;
            }
            this.$emit("showTicketInfo", this.ticket);
        },
        onTalkInfo() {
            this.$emit("showTalkInfo", this.ticket);
        },
    },
};
</script>

<style lang="less" scoped>
.ticket-item-container {
    width: 100%;
    padding: 16px 14px 0 14px;
    box-sizing: border-box;

    .title-wrapper {
        display: flex;
        .icon {
            width: 16px;
            height: 16px;
            background-image: url("../../assets/img/ticket-icon.png");
            background-size: 16px 16px;
            display: inline-block;
            background-position: center;
            background-repeat: no-repeat;
            border-radius: 50%;
        }
        .label {
            font-size: 13px;
            font-weight: 400;
            color: #3c4244;
            line-height: 18px;
            margin-left: 8px;
        }
        .button-wrapper {
            margin-left: auto;
            .button {
                font-size: 13px;
                font-weight: 500;
                color: #6483a5;
                line-height: 18px;
                margin-right: 6px;
            }
            .status {
                font-size: 13px;
                font-weight: 400;
                color: #9da0a1;
                line-height: 18px;
            }
        }
    }

    .content-wrapper {
        .left {
            width: 50%;
            display: inline-block;
        }
        .right {
            width: 50%;
            display: inline-block;
        }
        .label {
            font-size: 14px;
            font-weight: 400;
            color: #9a9ea0;
            line-height: 20px;
        }
        .value {
            font-size: 14px;
            font-weight: 500;
            color: #3c4244;
            line-height: 20px;
        }
    }

    .info-button {
        width: fit-content;
        left: auto;
        float: right;
        height: 28px;
        border-radius: 14px;
        border: 1px solid #e6e6e6;
        font-size: 13px;
        font-weight: 400;
        color: #242728;
        line-height: 28px;
        position: relative;
        // left: calc(100% - 89px);
    }

    .divider {
        width: 100%;
        height: 1px;
        background: #e7e7e7;
        display: inline-block;
    }
    .content-line {
        margin: 0;
        margin-top: 12px;
    }
    .blank {
        display: inline-block;
        height: 16px;
        width: 100%;
    }
}
</style>
